﻿import os, xlrd, arcpy, arcgisscripting, sys


def getRadians(content):
    if content.find("a") < 0 and content.find("b") < 0 and content.find("c") < 0:
        return content.strip()

    data_dir = 1
    print "content:{0}".format(content)
    if content.find("S") > 0 or content.find("W") > 0:
        data_dir = -1
    content = content.replace("N", "").replace("E", "").replace("S", "").replace("W", "")

    a = content.split('a')[0].strip()
    a_ = content.split('a')[1].strip()

    if a_ == '':
        return data_dir * float(a)
    elif a_.find('b') > 0:
        b = a_.split('b')[0].strip()
        b_ = a_.split('b')[1].strip()
        if b_ == '':
            return data_dir * (float(a) + float(b) / 60)
        elif b_.find('c') > 0:
            c = b_.split('c')[0]
            return data_dir * (float(a) + float(b) / 60 + float(c) / 3600)
    elif a_.find('c')>0:
        c = a_.split('c')[0].strip()
        return data_dir * (float(a) + float(c) / 3600)
